import React, { useEffect, useState } from 'react'
import { DouyinItems } from '@/api/douyin/types';
import instance from '@/utils/http';

export default function DouyinCom() {
  //定义一个状态
  let [douyin, setDouyin] = useState<DouyinItems>([]);
  useEffect(() => {
    //声明函数
    let getData = async() => {
      //发送请求  http://api.xiaohigh.com/douyin
      let result = await instance.get<any,DouyinItems>('/douyin');
      // result.data[0].
      setDouyin(result);
    }

    getData();
  }, [])
  return (
    <div>
      <ul>
        {
          douyin.map(item => {
            return <li key={item.id}><a href={'http://cdn.xiaohigh.com' + item.video_local}>{item.desc}</a></li>;
          })
        }
        
      </ul>
    </div>
  )
}
